﻿using System;
using System.Net;
using System.Linq;
using System.Collections.Generic;
using System.Windows.Input;

namespace SilverTile.Keybard
{
    public class KeyState : IKeyState
    {

        public KeyState(params Key[] keys)
        {
            Keys = keys;
        }

        public KeyState()
        { }

        #region IKeyState Members

        public Action Activated
        {
            get;
            set;
        }

        public Action Deactivated
        {
            get;
            set;
        }

        private Key[] _keys;
        public IEnumerable<Key> Keys
        {
            get { return _keys; }
            set { _keys = value.ToArray(); }
        }

        public Key Key
        {
            get
            {
                if (_keys.Length != 1)
                {
                    throw new InvalidOperationException("Cannot return signle key when " + _keys.Length + " keys are assigned to KeyState");
                }
                return _keys[0];
            }
            set
            {
                _keys = new Key[] { value };
            }
        }

        public Boolean IsActive { get; set; }

        #endregion
    }
}
